package com.sx.service.utils;

import com.sx.service.utils.sender.ISenderService;
import com.sx.service.utils.sender.SenderFactory;
import com.sx.service.utils.sender.SenderType;
import com.sx.service.utils.sender.model.MailRequest;
import com.sx.service.utils.sender.model.SmsRequest;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author AdinZ
 * @date 2020/11/11 18:24
 */
@Service
public class SenderService {
    @Resource private SenderFactory factory;

    public boolean sendSms(String areaCode,String mobile,String content) {
        SmsRequest request = null;//new SmsRequest(areaCode, content).setTo(mobile);
        ISenderService senderService = factory.getService(SenderType.SMS);
        return senderService.sender(request);
    }
    public boolean sendEmail(String to,String subject,String content){
        MailRequest request=new MailRequest(to, subject, content);
        ISenderService senderService = factory.getService(SenderType.EMAIL);
        return senderService.sender(request);
    }




}
